/**
 * @class Ext.app.ConfigFTPServerWindow
 * @extends Ext.panel.Window
 */
Ext.define('Ext.app.ConfigFTPServerWindow', {
    extend: 'Ext.window.Window',
    alias: 'widget.configFTPServerWindow',

    id: 'configFTPServerWindow',
    height: 230,
    width: 400,
    layout: 'border',
    items: [
        {
            xtype: 'toolbar',
            region: 'north',
            items: [
                {
                    text: this.translations.get("ACTION.VALIDATE"),
                    handler : this.functions.get("ACTION.CONFIGURE_FTP_SERVER")
                },
                {
                    text: this.translations.get("ACTION.CANCEL"),
                    handler : function(button, e) {
                        var wind = button.up('configFTPServerWindow');
                        if(wind != null) {
                            wind.close();
                        }
                    }
                }
            ]
        }, 
        {
            region: 'center',
            xtype: 'panel',
            bodyPadding: 15,
            defaults: {
                labelWidth: 100
            },
            items: [
                {
                    xtype: 'textfield',
                    fieldLabel: this.translations.get("HOME.FTP_SERVER"),
                    width: 350,
                    name: 'FTPServer'
                },
                {
                    xtype: 'textfield',
                    fieldLabel: this.translations.get("HOME.LOGIN"),
                    width: 350,
                    name: 'login'
                },
                {
                    xtype: 'textfield',
                    fieldLabel: this.translations.get("HOME.PASSWORD"),
                    width: 350,
                    inputType: 'password',
                    name: 'password'
                },
                {
                    xtype: 'textfield',
                    fieldLabel: this.translations.get("HOME.PASSIVE_MODE"),
                    width: 350,
                    name: 'passiveMode'
                },
                {
                    xtype: 'button',
                    text: this.translations.get("HOME.CHECK_SITE"),
                    handler : this.functions.get("ACTION.CHECK_FTP_SITE")
                }
            ]
        }
    ],
    
    constructor: function (translations, functions) {
        this.translations = translations;
        this.functions = functions;
        
        this.callParent(arguments);
    },
    
    listeners: {
        beforeclose: function () {
            Ext.getBody().unmask();
        }
    },
    
    initComponent : function() {
        Ext.getBody().mask();
        
        this.title = this.translations.get("HOME.CONFIGURE_FTP_SERVER_TITLE");
        this.callParent();
    },
    
    getValue: function(selector) {
        var cmp = this.down(selector);
        return (cmp == null ? "" : cmp.getValue());
    },

    getData: function() {
        return {
            "FTPServer": this.getValue("[name=FTPServer]"), 
            "login": this.getValue("[name=login]"),
            "password": this.getValue("[name=password]"),
            "passiveMode": this.getValue("[name=passiveMode]")
        };
    }
});
